//
//  FSBaseTableController.m
//  fanshu
//
//  Created by mh on 16/3/27.
//  Copyright © 2016年 FS. All rights reserved.
//

#import "FSBaseTableController.h"
#import "FSDisCoverArticleCell.h"
#import "FSDisCoverFrameModel.h"
#import "MJRefresh.h"
@interface FSBaseTableController ()

@end

@implementation FSBaseTableController

#pragma mark - 懒加载
- (NSMutableArray *)dataArray{
    if (_dataArray == nil) {
        _dataArray = [NSMutableArray array];
    }
    return _dataArray;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor colorWithRed:arc4random_uniform(256) / 255.0 green:arc4random_uniform(256) / 255.0 blue:arc4random_uniform(256) / 255.0 alpha:1.0];
    self.tableView.showsVerticalScrollIndicator = NO;
}

#pragma mark - TableView dataSourse
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *ID = @"discoverCell";
    FSDisCoverArticleCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        cell = [[FSDisCoverArticleCell alloc] initWithStyle: UITableViewCellStyleSubtitle reuseIdentifier:ID];
    }
    FSDisCoverFrameModel *frameModel = self.dataArray[indexPath.row];
    cell.frameModel = frameModel;
    return cell;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.dataArray.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return [self.dataArray[indexPath.row] cellHeight];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}
@end
